<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript">
        // 编写一个对象
        var user={
            name:"tom",
            age:12,
            sex:"男",
        }
        console.log(user)
        // 转换为json字符串
        var json = JSON.stringify(user);
        console.log(json)
        console.log("----------------")
        //将json字符串转换为对象
        var obj = JSON.parse(json);
        console.log(obj)
    </script>
</head>
<body>

</body>
</html>